package com.four.dailymanage.office.dao;

import com.four.dailymanage.office.entity.Office;
import com.four.dailymanage.repair.entity.RepairApply;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OfficeDao {
    //增加
    @Insert("insert into office (applyDept,handleMan,applyDt,applyType,applyTypeDetail,num,note,submitDt,examineStatus)  values " +
            "(#{applyDept},#{handleMan},#{applyDt},#{applyType},#{applyTypeDetail},#{num},#{note},#{submitDt},#{examineStatus})")
    public int  addOffice(Office office);
    //删除
    @Delete("delete from office where id =#{id}")
    public int deleteById(Integer id);
    //修改
    @Update("<script>" +
            "update  office " +
            "        <set>" +
            "            <if test=\"null!= examineStatus\">" +
            "                examineStatus =#{examineStatus}," +
            "            </if>" +
            "            <if test=\"null!= submitDt\">" +
            "                submitDt =#{submitDt}," +
            "            </if>" +
            "        </set>" +
            "        where id =#{id}" +
            "</script>")
    public int updateById(Office office);
    //查询
    //分页查询
    @Select("<script>" +
            "SELECT office.*,office_type.typeName,officetype_detail.detailName FROM office left join" +
            "  office_type on office.applyType=office_type.id left join  officetype_detail on office.applyTypeDetail=officetype_detail.id  " +
            "<where>" +
            "    <if test=\" applyType != null\">" +
            "       applyType = #{applyType} " +
            "    </if>" +
            "    <if test=\" examineStatus != null\">" +
            "       and examineStatus = #{examineStatus} " +
            "    </if>" +
            "    <if test=\" handleMan != null\">" +
            "       handleMan = #{handleMan} " +
            "    </if>" +
            "</where>"+
            "limit #{start},#{size}"+
            "</script>")

    public List<Office> getOfficeByCon(int start, int size,String handleMan,String examineStatus, String applyType);

    @Select("<script>" +
            "select count(*) from office" +
            "  <where>" +
            "    <if test=\" applyType != null\">" +
            "       applyType = #{applyType} " +
            "    </if>" +
            "    <if test=\" examineStatus != null\">" +
            "       and examineStatus = #{examineStatus} " +
            "    </if>" +
            "    <if test=\" handleMan != null\">" +
            "       handleMan = #{handleMan} " +
            "    </if>" +
            "</where>"+
            "</script>")
    public  int countOffice(String handleMan,String examineStatus, String applyType);
}
